<template>
    <div>
<h1>登录</h1>
<table class="table">
<tbody>
    <tr>
        <td>用户名</td>
        <td>
            <input type="text" v-model="da.username">
        </td>
    </tr>

    <tr>
        <td>密码</td>
        <td>
            <input type="password" v-model="da.password">
        </td>
    </tr>

    <tr>
        <td></td>
        <td>
           <input type="button" value="登录" @click="dl">
        </td>
    </tr>
</tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const us=useRouter()
const da=ref({
    username:"",
    password:""
})

const dl=()=>{
    axios.get("https://localhost:7020/api/MD/Login",{params:da.value}).then(res=>{
        if(res.data.dlId==-1){
            alert("用户名不存在")
            return
        }if(res.data.dlId==-2){
            alert("密码错误")
            return
        }
        if(res.data.dlId>0){
            alert("登录成功")
us.push({path:"/"})
        }
    })
}
</script>

<style scoped>

</style>
